<?php
	//修改个人密码
	require '../biz/backend.php';

	class action extends backend
	{
		function do_get()
		{
			$this->input['reference'] = 'entrance.php';
			$template = load( 'template', array( 'domain'=>'tpl.admin' ) );
			$template->assign( 'reference', isset( $this->input['reference'] ) ? urldecode( $this->input['reference'] ) : config( 'server.HTTP_REFERER' ) );
			echo $template->parse( 'set_password.php' );
		}

		function do_post()
		{
			$url = isset( $this->input['reference'] ) ? $this->input['reference'] : config( 'domain.admin' ) . 'set_config.php';
			unset( $this->input['reference'] );

			$account = load( 'biz.account' );
			$result = $account->set_password( $this->input );

			if ( $result == '0' )
			{
				$this->prompt( '成功修改密码', array( array( 'url' => config( 'domain.admin' ) . 'entrance.php', 'name' => '返回首页' ), array( 'url' => config( 'domain.admin' ) . 'set_password.php?reference=' . urlencode( $url ), 'name' => '重新修改密码' ) ) );
			}
			else
			{
				$result = $result == '1' ? '提示' : ( $result == '2' ? '输入密码错误' : '未知错误' . $result );
				$this->prompt( $result, array( array( 'url' => config( 'server.HTTP_REFERER' ), 'name' => '修改失败,旧密码错误.返回' ) ) );
			}
		}
	}

	$action = new action();
	$action->run();
?>